package com.fenghongzhang.club_2303

import com.fenghongzhang.club_2303.test.FengUser
import com.fenghongzhang.club_2303.test.Used
import org.junit.Test

import org.junit.Assert.*
import java.lang.reflect.Method

/**
 * Example local unit test, which will execute on the development machine (host).
 *
 * See [testing documentation](http://d.android.com/tools/testing).
 */
class ExampleUnitTest {
    @Test
    fun addition_isCorrect() {
        val fengUserClass =  Class.forName("com.fenghongzhang.club_2303.test.FengUser")
        val fengUser =   fengUserClass.newInstance() as FengUser//创建对象

        val field = fengUserClass.getField("name")
        field.isAccessible = true
        val annotation = field.getAnnotation(Used::class.java)
        if (annotation != null) {
            println(annotation.value)
        }


//       val address =  fengUserClass.getMethod("setAddress",String::class.java,Int::class.java)
//        address.invoke(fengUser,"北京",12)
//
//        val cons =  fengUserClass.getConstructor(null)
//        val fengUser1 = cons.newInstance(null)

//        fengUserClass.declaredConstructors.forEach {
//            println( it)
//        }
//
////        val address =  fengUserClass.getDeclaredField("address")
////        address.isAccessible = true
////
////        address.set(fengUser,"北京")
//        println(fengUser.address)
//
//        fengUserClass.fields.forEach {
//           // println(it.name)
//        }
//        fengUserClass.declaredFields.forEach {
//            //println(it.name)
//        }
//
//
//        fengUserClass.methods.forEach {
//           // println(it.name)
//        }
//
//        fengUserClass.declaredMethods.forEach {
//           // println(it.name)
//        }
    }
}